// function Student(){}
// Student.prototype.study = function(){
//     console.log('html');
//     console.log('css');
//     console.log('js');
// }
// // 定义一个装饰类，对student类进行增强
// function Decorator(someBody){
//     this.someBody = someBody
//     this.someBody.ability = 'ability--'
//     return this.someBody
// }
// var jitao = new Student();
// jitao = new Decorator(jitao)
// console.log(jitao.ability);
// console.log(jitao instanceof Student);
// console.log(jitao instanceof Decorator);

function Student() { }
Student.prototype.study = function () {
    console.log('html');
    console.log('css');
    console.log('js');
}

// 定义一个装饰类,对Student类进行增强
function Decorator(someBody) {
    this.someBody = someBody
    // 把之前study方法备份一下
    this.someBody._study = someBody.study
    // 把Decorator构造器中生成的对象中的study，覆盖掉之前的study方法
    this.someBody.study = this.study
    return this.someBody
}
Decorator.prototype.study = function(){
    // 调用原本的study方法
    this._study();
    console.log('vue');
    console.log('react');
}
let jitao = new Student();

jitao = new Decorator(jitao)
jitao.study()